home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / July 96 / Bug, reading and writing to SU < prev    next >
Encoding:
Internet Message Format  |  1996-07-24  |  3.3 KB  |  [TEXT/ttxt]

  1. Subject:     Bug, reading and writing to SU
  2. Sent:        7/22/96 12:11 AM
  3. Received:    7/22/96 10:48 AM
  4. From:        Arni McKinley, motion@nbn.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. I have come across a situation which yields a crash in the following way:
  9. (1) I externalize my part, during which I write out a shapeList (ala
  10. ODFDraw) to a value in a property that I have added specially to the part's
  11. storage unit.
  12. (2) I then embed a part, using CProxyShape, like in ODFDraw, adding it to
  13. the above shapeList.
  14. (3) A bit later, but before the part is externalized, I get the storage
  15. unit from my part, and write out the shape list to that same value and
  16. property.
  17.  
  18. When it reaches the proxy, it passes through this code in
  19. FW_CProxyFrame::ExternalizeProxyFrame():
  20.         ODStorageUnitRef aSURef;
  21.         FW_CByteArray byteArray(&aSURef, sizeof(ODStorageUnitRef));
  22.         suView->GetStrongStorageUnitRef(ev, fFrameID, aSURef);
  23.         suView->SetValue(ev, byteArray);
  24.  
  25. (4) A bit later, I attempt to read the list back in. When the proxy is
  26. read,  this code is used in FW_CProxyFrame::InternalizeProxyFrame():
  27.         ODStorageUnitRef aSURef;
  28.         FW_CByteArray byteArray;
  29.  
  30.         // ----- Read reference -----
  31.         suView->GetValue(ev, sizeof(ODStorageUnitRef), byteArray);
  32.         byteArray.CopyBuffer(&aSURef, sizeof(ODStorageUnitRef));
  33.  
  34.         if (!suView->IsValidStorageUnitRef(ev, aSURef))
  35.                 return FALSE;
  36.  
  37. which is gets through just fine, so the 'aSURef' I wrote out is good. The
  38. code then attempts to set the proxy's 'fContainingFrameID':
  39.  
  40.    ODStorageUnitID fromFrameID = suView->GetIDFromStorageUnitRef(ev, aSURef);
  41.  
  42.    // ----- Save the frame's draft
  43.    fFrameDraft = suView->GetStorageUnit(ev)->GetDraft(ev);
  44.  
  45.    // ----- Cache the id of the containing frame -----
  46.    FW_CAcquiredODStorageUnit aqFrameSU =
  47. fFrameDraft->AcquireStorageUnit(ev, fromFrameID);
  48.    aqFrameSU->Focus(ev, kODPropContainingFrame, kODPosUndefined,
  49. kODWeakStorageUnitRef, 0, kODPosUndefined);
  50.  
  51.    aqFrameSU->GetValue(ev, sizeof(ODStorageUnitRef), byteArray);
  52.    byteArray.CopyBuffer(&aSURef, sizeof(ODStorageUnitRef));
  53.  
  54.    if (aqFrameSU->IsValidStorageUnitRef(ev, aSURef))
  55.          fContainingFrameID = aqFrameSU->GetIDFromStorageUnitRef(ev, aSURef);
  56.    else
  57.          fContainingFrameID = kODNULLID;
  58.  
  59.    // ----- Now we can set the frame ID -----
  60.    fFrameID = fromFrameID;
  61.  
  62. For some reason, aqFrameSU is invalid, so the fContainingFrameID becomes
  63. NULL. This makes it impossible for the proxy to find its containing frame,
  64. and a bit later, when I write out the list again, it crashes in
  65. FW_MProxy::Externalize() at the following line:
  66.  
  67.     if (proxyFrame->GetContainingFrame(ev)->IsPersistent(ev))
  68.        count++;
  69.  
  70. since the containing frame is NULL.
  71.  
  72. _______
  73. Uh, anyone know why there is no strong reference in the storage unit to the
  74. containing frame?
  75.  
  76. I have noticed that the storage unit can be found if I externalize the
  77. entire part just after embedding. I have no problem finding the proxy's
  78. containing frame thereafter.
  79.  
  80. Thanks,
  81.  
  82. Arni
  83.  
  84. _______________________________________
  85. Arnold F. McKinley
  86. President
  87. MetaMind Software, Inc.
  88. 342 Lowell Ave.
  89. Mill Valley, CA 94941
  90. 415-381-8063
  91. FAX: 415-389-8969
  92. motion@nbn.com
  93. _______________________________________
  94.  
  95.  
  96.